package com.zishi.venuesbooking.ac;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.zishi.venuesbooking.BaseActivity;
import com.zishi.venuesbooking.R;
import com.zishi.venuesbooking.adapter.MyRecordAdapter;
import com.zishi.venuesbooking.adapter.ReserveAdapter;
import com.zishi.venuesbooking.entity.MyRecord;
import com.zishi.venuesbooking.entity.Reserve;

import org.json.JSONException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MyRecordsActivity extends BaseActivity {

    private static final String TAG = "MyRecordsActivity";
    private RecyclerView rvMyRecords;
    private MyRecordAdapter adapter;
    private List<MyRecord> myRecords = new ArrayList<>();

    @Override
    protected int initLayout() {
        return R.layout.activity_my_records;
    }

    @Override
    protected void initView() {
        rvMyRecords = findViewById(R.id.all_my_records_list);

        // 设置评论列表
        adapter = new MyRecordAdapter(myRecords);
        rvMyRecords.setLayoutManager(new LinearLayoutManager(this));
        rvMyRecords.setAdapter(adapter);
    }

    @Override
    protected void initData() throws JSONException, IOException {
        loadMyRecords();
    }

    private void loadMyRecords() {
        // 模拟数据加载
        List<MyRecord> myRecords = new ArrayList<>();
        myRecords.add(new MyRecord("1",  "indoor badminton court","file:///android_asset/images/goods/good_avata_1.png",
                "time of appointement 19:30"));
        myRecords.add(new MyRecord("1",  "football playground court","file:///android_asset/images/goods/good_avata_2.png",
                "time of appointement 20:30"));
        myRecords.add(new MyRecord("1",  "bascketball Play yard","file:///android_asset/images/goods/good_avata_3.png",
                "time of appointement 7:30"));
        myRecords.add(new MyRecord("1",  "indoor swimming pool","file:///android_asset/images/goods/good_avata_4.png",
                "time of appointement 16:30"));

        adapter.updateData(myRecords);
        // 从网络或数据库加载评论数据
        // comments.addAll(...);
        // adapter.notifyDataSetChanged();
    }
}